* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --background: #ffffff;
    --surface: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

.background-blur {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    z-index: -1;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.language-selector select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo i {
    color: var(--primary-color);
    font-size: 1.8rem;
}

.add-widget-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-size: 0.95rem;
}

.add-widget-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Widget Panel */
.widget-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.widget-panel.active {
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.panel-header {
    background: var(--primary-color);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.panel-content {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.widget-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.widget-type-card {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.widget-type-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.widget-type-card.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.widget-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.widget-info h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.widget-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.config-section {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.config-section h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

.config-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 15px;
    background: white;
}

.config-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.create-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    width: 100%;
    justify-content: center;
}

.create-btn:hover {
    background: var(--primary-hover);
}

/* Configuration Help */
.config-help {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.config-example h5 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-fields {
    margin-bottom: 20px;
}

.field {
    margin-bottom: 15px;
}

.field strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 5px;
}

.field-example {
    background: var(--secondary-color);
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 5px;
}

.field-example code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
    background: none;
}

.config-sample {
    background: var(--secondary-color);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.config-sample strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 10px;
}

.config-sample pre {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin: 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    min-height: 500px;
}

/* Widget Cards */
.widget-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.widget-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
}

.widget-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.widget-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.widget-title i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.widget-title h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-actions {
    display: flex;
    gap: 8px;
}

.widget-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.widget-btn:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.widget-btn.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.widget-content {
    background: var(--secondary-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.widget-data {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.widget-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.widget-id {
    font-family: monospace;
    background: var(--secondary-color);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: white;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.empty-state h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 999;
    display: none;
}

.overlay.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .main-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .widget-panel {
        width: 95%;
        max-height: 90vh;
    }
    
    .panel-content {
        padding: 20px;
        overflow-y: auto;
        flex: 1;
    }
    
    .widget-types {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.widget-card {
    animation: fadeIn 0.5s ease-out;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Custom Scrollbar for Panel Content */
.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* For Firefox */
.panel-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) rgba(0, 0, 0, 0.1);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Widget-specific styles */
.todo-widget, .calendar-widget {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.todo-header, .calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.todo-header h3, .calendar-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.add-todo-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.add-todo-btn:hover {
    background: var(--primary-hover);
}

.todo-list {
    margin-bottom: 20px;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.todo-item:hover {
    transform: translateX(4px);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
}

.todo-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.todo-text {
    flex: 1;
    color: var(--text-primary);
}

.todo-priority {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.todo-priority.high {
    background: #fee2e2;
    color: #dc2626;
}

.todo-priority.medium {
    background: #fef3c7;
    color: #d97706;
}

.todo-priority.low {
    background: #dbeafe;
    color: #2563eb;
}

.todo-actions {
    display: flex;
    gap: 8px;
}

.todo-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.todo-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.todo-btn.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.todo-stats {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Calendar Widget Styles */
.calendar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-controls button {
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.calendar-controls button:hover {
    background: var(--secondary-color);
}

.calendar-view {
    margin: 20px 0;
    min-height: 200px;
}

.calendar-events {
    max-height: 200px;
    overflow-y: auto;
}

.event-item {
    padding: 10px;
    background: var(--secondary-color);
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary-color);
}

.event-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.event-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.event-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 4px;
}

.event-type.meeting {
    background: #dbeafe;
    color: #1e40af;
}

.event-type.reminder {
    background: #fef3c7;
    color: #92400e;
}

.event-type.deadline {
    background: #fee2e2;
    color: #991b1b;
}

/* Modal for adding todos/events */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.modal-actions .btn-primary {
    background: var(--primary-color);
    color: white;
}

.modal-actions .btn-primary:hover {
    background: var(--primary-hover);
}

.modal-actions .btn-secondary {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.modal-actions .btn-secondary:hover {
    background: var(--border-color);
}

/* Authentication Styles */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

.username {
    font-weight: 500;
    color: var(--text-primary);
}

.user-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.user-menu-btn:hover {
    background: var(--secondary-color);
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    display: none;
    margin-top: 8px;
}

.user-menu.active {
    display: block;
}

.user-menu button {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu button:hover {
    background: var(--secondary-color);
}

.login-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.login-btn:hover {
    background: var(--primary-hover);
}

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

.login-info p {
    margin: 0;
    color: var(--text-secondary);
}

.login-submit-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.login-submit-btn:hover {
    background: var(--primary-hover);
}

/* Admin User Management Styles */
.admin-actions {
    margin-bottom: 20px;
}

.add-user-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.add-user-btn:hover {
    background: var(--primary-hover);
}

.user-list {
    margin-bottom: 20px;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.user-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-item-username {
    font-weight: 500;
    color: var(--text-primary);
}

.user-item-role {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.user-item-role.admin {
    background: #fee2e2;
    color: #dc2626;
}

.user-item-role.user {
    background: #dbeafe;
    color: #2563eb;
}

.user-item-actions {
    display: flex;
    gap: 8px;
}

.user-item-actions button {
    background: none;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.user-item-actions button.delete {
    color: #dc2626;
}

.user-item-actions button.delete:hover {
    background: #fee2e2;
}

.add-user-form {
    padding: 20px;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-top: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.submit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.submit-btn:hover {
    background: var(--primary-hover);
}

.cancel-btn {
    background: var(--border-color);
    color: var(--text-primary);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.cancel-btn:hover {
    background: var(--text-secondary);
    color: white;
}

/* Admin menu item in user menu */
.admin-menu-item {
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 4px;
}